package org.aeon.utils;

import java.util.Random;

/**
 * @author: MissingAeon
 * @date: 2024/3/12 9:49
 * @description:
 */
public class RandomUtils {
    private static final Random random = new Random();

    /**
     * 获取原数随机倍数
     *
     * @param old
     * @param maximumFactor
     * @param minimalFactor
     * @return
     */
    public static long random(long old, double maximumFactor, double minimalFactor) {
        return (long) (old * (minimalFactor + random.nextDouble() * (maximumFactor - minimalFactor)));
    }

    /**
     * 获取原数随机倍数
     *
     * @param old
     * @param maximumFactor
     * @param minimalFactor
     * @return
     */
    public static int random(int old, double maximumFactor, double minimalFactor) {
        return (int) (old * (minimalFactor + random.nextDouble() * (maximumFactor - minimalFactor)));
    }

    /**
     * 获取原数随机倍数
     *
     * @param old
     * @param maximumFactor
     * @param minimalFactor
     * @return
     */
    public static double random(double old, double maximumFactor, double minimalFactor) {
        return old * (minimalFactor + random.nextDouble() * (maximumFactor - minimalFactor));
    }
}
